#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

from pymongo import MongoClient


def map_do():
    client = MongoClient("10.188.188.22", 27017)
    db = client["Dictionary"]
    collection = db["DiseaseOntology_20190627"]

    infile = open("/Users/genesis/Downloads/Disease2DO.txt", "r")
    for line in infile:
        line = line.rstrip()
        result = collection.find_one({"dms_synonym_extend": {"$regex": "^" + line + "$", "$options": "$i"}})
        if result is not None:
            print("DOID:" + result["dms_id"])
        else:
            print("None")

    client.close()


if __name__ == '__main__':
    map_do()
